package org.jdesktop.swingx.renderer;

import javax.swing.*;
import java.awt.*;

/**
 * Table specific <code>CellContext</code>.
 */
public class TableCellContext extends CellContext<JTable> {
    private int width;

    /**
     * Returns the cell's editable property as returned by table.isCellEditable
     * or false if the table is null.
     *
     * @return the cell's editable property.
     */
    @Override
    public boolean isEditable() {
        return getComponent() != null && getComponent().isCellEditable(getRow(), getColumn());
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected Color getSelectionBackground() {
        return getComponent() != null ? getComponent().getSelectionBackground() : null;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected Color getSelectionForeground() {
        return getComponent() != null ? getComponent().getSelectionForeground() : null;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected String getUIPrefix() {
        return "Table.";
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }
}